actor.ensure_style();
}
-function PopupBaseMenuItem(params) {
- this._init(params);
-}
+const PopupBaseMenuItem = new Lang.Class({
+ Name: 'PopupBaseMenuItem',
-PopupBaseMenuItem.prototype = {
_init: function (params) {
params = Params.parse (params, { reactive: true,
activate: true,
x -= availWidth + this._spacing;
}
}
-};
+});
Signals.addSignalMethods(PopupBaseMenuItem.prototype);
-function PopupMenuItem() {
- this._init.apply(this, arguments);
-}
-
-PopupMenuItem.prototype = {
- __proto__: PopupBaseMenuItem.prototype,
+const PopupMenuItem = new Lang.Class({
+ Name: 'PopupMenuItem',
+ Extends: PopupBaseMenuItem,
_init: function (text, params) {
- PopupBaseMenuItem.prototype._init.call(this, params);
+ this.parent(params);
this.label = new St.Label({ text: text });
this.addActor(this.label);
}
-};
-
-function PopupSeparatorMenuItem() {
- this._init();
-}
+});
-PopupSeparatorMenuItem.prototype = {
- __proto__: PopupBaseMenuItem.prototype,
+const PopupSeparatorMenuItem = new Lang.Class({
+ Name: 'PopupSeparatorMenuItem',
+ Extends: PopupBaseMenuItem,
_init: function () {
- PopupBaseMenuItem.prototype._init.call(this, { reactive: false });
+ this.parent({ reactive: false });
this._drawingArea = new St.DrawingArea({ style_class: 'popup-separator-menu-item' });
this.addActor(this._drawingArea, { span: -1, expand: true });
cr.rectangle(margin, gradientOffset, gradientWidth, gradientHeight);
cr.fill();
}
-};
+});
const PopupAlternatingMenuItemState = {
DEFAULT: 0,
ALTERNATIVE: 1
}
-function PopupAlternatingMenuItem() {
- this._init.apply(this, arguments);
-}
-
-PopupAlternatingMenuItem.prototype = {
- __proto__: PopupBaseMenuItem.prototype,
+const PopupAlternatingMenuItem = new Lang.Class({
+ Name: 'PopupAlternatingMenuItem',
+ Extends: PopupBaseMenuItem,
_init: function(text, alternateText, params) {
- PopupBaseMenuItem.prototype._init.call(this, params);
+ this.parent(params);
this.actor.add_style_class_name('popup-alternating-menu-item');
this._text = text;
this._updateLabel();
}
-};
-
-function PopupSliderMenuItem() {
- this._init.apply(this, arguments);
-}
+});
-PopupSliderMenuItem.prototype = {
- __proto__: PopupBaseMenuItem.prototype,
+const PopupSliderMenuItem = new Lang.Class({
+ Name: 'PopupSliderMenuItem',
+ Extends: PopupBaseMenuItem,
_init: function(value) {
- PopupBaseMenuItem.prototype._init.call(this, { activate: false });
+ this.parent({ activate: false });
this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
}
return false;
}
-};
+});
-function Switch() {
- this._init.apply(this, arguments);
-}
+const Switch = new Lang.Class({
+ Name: 'Switch',
-Switch.prototype = {
_init: function(state) {
this.actor = new St.Bin({ style_class: 'toggle-switch' });
// Translators: this MUST be either "toggle-switch-us"
toggle: function() {
this.setToggleState(!this.state);
}
-};
-
-function PopupSwitchMenuItem() {
- this._init.apply(this, arguments);
-}
+});
-PopupSwitchMenuItem.prototype = {
- __proto__: PopupBaseMenuItem.prototype,
+const PopupSwitchMenuItem = new Lang.Class({
+ Name: 'PopupSwitchMenuItem',
+ Extends: PopupBaseMenuItem,
_init: function(text, active, params) {
- PopupBaseMenuItem.prototype._init.call(this, params);
+ this.parent(params);
this.label = new St.Label({ text: text });
this._switch = new Switch(active);
setToggleState: function(state) {
this._switch.setToggleState(state);
}
-};
+});
-function PopupImageMenuItem() {
- this._init.apply(this, arguments);
-}
-
-PopupImageMenuItem.prototype = {
- __proto__: PopupBaseMenuItem.prototype,
+const PopupImageMenuItem = new Lang.Class({
+ Name: 'PopupImageMenuItem',
+ Extends: PopupBaseMenuItem,
_init: function (text, iconName, params) {
- PopupBaseMenuItem.prototype._init.call(this, params);
+ this.parent(params);
this.label = new St.Label({ text: text });
this.addActor(this.label);
setIcon: function(name) {
this._icon.icon_name = name;
}
-};
+});
-function PopupMenuBase() {
- throw new TypeError('Trying to instantiate abstract class PopupMenuBase');
-}
+const PopupMenuBase = new Lang.Class({
+ Name: 'PopupMenuBase',
+ Abstract: true,
-PopupMenuBase.prototype = {
_init: function(sourceActor, styleClass) {
this.sourceActor = sourceActor;
this.emit('destroy');
}
-};
+});
Signals.addSignalMethods(PopupMenuBase.prototype);
-function PopupMenu() {
- this._init.apply(this, arguments);
-}
-
-PopupMenu.prototype = {
- __proto__: PopupMenuBase.prototype,
+const PopupMenu = new Lang.Class({
+ Name: 'PopupMenu',
+ Extends: PopupMenuBase,
_init: function(sourceActor, arrowAlignment, arrowSide) {
- PopupMenuBase.prototype._init.call (this, sourceActor, 'popup-menu-content');
+ this.parent(sourceActor, 'popup-menu-content');
this._arrowAlignment = arrowAlignment;
this._arrowSide = arrowSide;
this.isOpen = false;
this.emit('open-state-changed', false);
}
-};
-
-function PopupSubMenu() {
- this._init.apply(this, arguments);
-}
+});
-PopupSubMenu.prototype = {
- __proto__: PopupMenuBase.prototype,
+const PopupSubMenu = new Lang.Class({
+ Name: 'PopupSubMenu',
+ Extends: PopupMenuBase,
_init: function(sourceActor, sourceArrow) {
- PopupMenuBase.prototype._init.call(this, sourceActor);
+ this.parent(sourceActor);
this._arrow = sourceArrow;
this._arrow.rotation_center_z_gravity = Clutter.Gravity.CENTER;
return false;
}
-};
+});
/**
* PopupMenuSection:
* can add it to another menu), but is completely transparent
* to the user
*/
-function PopupMenuSection() {
- this._init.apply(this, arguments);
-}
-
-PopupMenuSection.prototype = {
- __proto__: PopupMenuBase.prototype,
+const PopupMenuSection = new Lang.Class({
+ Name: 'PopupMenuSection',
+ Extends: PopupMenuBase,
_init: function() {
- PopupMenuBase.prototype._init.call(this);
+ this.parent();
this.actor = this.box;
this.actor._delegate = this;
// corresponding signal so children can still pick it up
open: function(animate) { this.emit('open-state-changed', true); },
close: function() { this.emit('open-state-changed', false); },
-}
-
-function PopupSubMenuMenuItem() {
- this._init.apply(this, arguments);
-}
+});
-PopupSubMenuMenuItem.prototype = {
- __proto__: PopupBaseMenuItem.prototype,
+const PopupSubMenuMenuItem = new Lang.Class({
+ Name: 'PopupSubMenuMenuItem',
+ Extends: PopupBaseMenuItem,
_init: function(text) {
- PopupBaseMenuItem.prototype._init.call(this);
+ this.parent();
this.actor.add_style_class_name('popup-submenu-menu-item');
destroy: function() {
this.menu.destroy();
- PopupBaseMenuItem.prototype.destroy.call(this);
+
+ this.parent();
},
_onKeyPressEvent: function(actor, event) {
return true;
}
- return PopupBaseMenuItem.prototype._onKeyPressEvent.call(this, actor, event);
+ return this.parent(actor, event);
},
activate: function(event) {
_onButtonReleaseEvent: function(actor) {
this.menu.toggle();
}
-};
-
-function PopupComboMenu() {
- this._init.apply(this, arguments);
-}
+});
-PopupComboMenu.prototype = {
- __proto__: PopupMenuBase.prototype,
+const PopupComboMenu = new Lang.Class({
+ Name: 'PopupComboMenu',
+ Extends: PopupMenuBase,
_init: function(sourceActor) {
- PopupMenuBase.prototype._init.call(this,
- sourceActor, 'popup-combo-menu');
+ this.parent(sourceActor, 'popup-combo-menu');
+
this.actor = this.box;
this.actor._delegate = this;
this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
getItemVisible: function(position) {
return this._getMenuItems()[position].actor.visible;
}
-};
+});
-function PopupComboBoxMenuItem() {
- this._init.apply(this, arguments);
-}
-
-PopupComboBoxMenuItem.prototype = {
- __proto__: PopupBaseMenuItem.prototype,
+const PopupComboBoxMenuItem = new Lang.Class({
+ Name: 'PopupComboBoxMenuItem',
+ Extends: PopupBaseMenuItem,
_init: function (params) {
- PopupBaseMenuItem.prototype._init.call(this, params);
+ this.parent(params);
this._itemBox = new Shell.Stack();
this.addActor(this._itemBox);
this.setActiveItem(position);
this.emit('active-item-changed', position);
}
-};
+});
/* Basic implementation of a menu manager.
* Call addMenu to add menus
*/
-function PopupMenuManager(owner) {
- this._init(owner);
-}
+const PopupMenuManager = new Lang.Class({
+ Name: 'PopupMenuManager',
-PopupMenuManager.prototype = {
_init: function(owner) {
this._owner = owner;
this.grabbed = false;
if (this._activeMenu != null)
this._activeMenu.close(true);
}
-};
+});
return label;
}
-function NMNetworkMenuItem() {
- this._init.apply(this, arguments);
-}
-
-NMNetworkMenuItem.prototype = {
- __proto__: PopupMenu.PopupBaseMenuItem.prototype,
+const NMNetworkMenuItem = new Lang.Class({
+ Name: 'NMNetworkMenuItem',
+ Extends: PopupMenu.PopupBaseMenuItem,
_init: function(accessPoints, title, params) {
- PopupMenu.PopupBaseMenuItem.prototype._init.call(this, params);
+ this.parent(params);
accessPoints = sortAccessPoints(accessPoints);
this.bestAP = accessPoints[0];
apObj.updateId = 0;
}
- PopupMenu.PopupBaseMenuItem.prototype.destroy.call(this);
+ this.parent();
}
-};
-
-function NMWiredSectionTitleMenuItem() {
- this._init.apply(this, arguments);
-}
+});
-NMWiredSectionTitleMenuItem.prototype = {
- __proto__: PopupMenu.PopupSwitchMenuItem.prototype,
+const NMWiredSectionTitleMenuItem = new Lang.Class({
+ Name: 'NMWiredSectionTitleMenuItem',
+ Extends: PopupMenu.PopupSwitchMenuItem,
_init: function(label, params) {
params = params || { };
params.style_class = 'popup-subtitle-menu-item';
- PopupMenu.PopupSwitchMenuItem.prototype._init.call(this, label, false, params);
+ this.parent(label, false, params);
},
updateForDevice: function(device) {
},
activate: function(event) {
- PopupMenu.PopupSwitchMenuItem.prototype.activate.call(this, event);
+ this.parent(event);
if (!this._device) {
log('Section title activated when there is more than one device, should be non reactive');
else
this._device.deactivate();
}
-};
-
-function NMWirelessSectionTitleMenuItem() {
- this._init.apply(this, arguments);
-}
+});
-NMWirelessSectionTitleMenuItem.prototype = {
- __proto__: PopupMenu.PopupSwitchMenuItem.prototype,
+const NMWirelessSectionTitleMenuItem = new Lang.Class({
+ Name: 'NMWirelessSectionTitleMenuItem',
+ Extends: PopupMenu.PopupSwitchMenuItem,
_init: function(client, property, title, params) {
params = params || { };
params.style_class = 'popup-subtitle-menu-item';
- PopupMenu.PopupSwitchMenuItem.prototype._init.call(this, title, false, params);
+ this.parent(title, false, params);
this._client = client;
this._property = property + '_enabled';
},
activate: function(event) {
- PopupMenu.PopupSwitchMenuItem.prototype.activate.call(this, event);
+ this.parent(event);
this._client[this._setEnabledFunc](this._switch.state);
},
this.emit('enabled-changed', enabled);
}
-};
+});
function NMDevice() {
throw new TypeError('Instantanting abstract class NMDevice');
// Copyright (C) 2008,2009 Red Hat, Inc.
-function IMStatusItem(label, iconName) {
- this._init(label, iconName);
-}
-
-IMStatusItem.prototype = {
- __proto__: PopupMenu.PopupBaseMenuItem.prototype,
+const IMStatusItem = new Lang.Class({
+ Name: 'IMStatusItem',
+ Extends: PopupMenu.PopupBaseMenuItem,
_init: function(label, iconName) {
- PopupMenu.PopupBaseMenuItem.prototype._init.call(this);
+ this.parent();
this.actor.add_style_class_name('status-chooser-status-item');
this.label = new St.Label({ text: label });
this.addActor(this.label);
}
-};
-
-function IMUserNameItem() {
- this._init();
-}
+});
-IMUserNameItem.prototype = {
- __proto__: PopupMenu.PopupBaseMenuItem.prototype,
+const IMUserNameItem = new Lang.Class({
+ Name: 'IMUserNameItem',
+ Extends: PopupMenu.PopupBaseMenuItem,
_init: function() {
- PopupMenu.PopupBaseMenuItem.prototype._init.call(this,
- { reactive: false,
- style_class: 'status-chooser-user-name' });
+ this.parent({ reactive: false,
+ style_class: 'status-chooser-user-name' });
this._wrapper = new Shell.GenericContainer();
this._wrapper.connect('get-preferred-width',
_wrapperAllocate: function(actor, box, flags) {
this.label.allocate(box, flags);
}
-};
+});
-function IMStatusChooserItem() {
- this._init();
-}
-
-IMStatusChooserItem.prototype = {
- __proto__: PopupMenu.PopupBaseMenuItem.prototype,
+const IMStatusChooserItem = new Lang.Class({
+ Name: 'IMStatusChooserItem',
+ Extends: PopupMenu.PopupBaseMenuItem,
_init: function() {
- PopupMenu.PopupBaseMenuItem.prototype._init.call (this,
- { reactive: false,
- style_class: 'status-chooser' });
+ this.parent({ reactive: false,
+ style_class: 'status-chooser' });
this._iconBin = new St.Button({ style_class: 'status-chooser-user-icon' });
this.addActor(this._iconBin);
this._userChangedId = 0;
}
- PopupMenu.PopupBaseMenuItem.prototype.destroy.call(this);
+ this.parent();
},
// Override getColumnWidths()/setColumnWidths() to make the item
this._expectedPresence = newPresence;
this._accountMgr.set_all_requested_presences(newPresence, status, msg);
}
-};
+});
function UserMenuButton() {